home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
tegl6b.zip
/
INTROPAK.EXE
/
lha
/
MENUDEMO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-06-26
|
16KB
|
394 lines
{-----------------------------------------------------------------------------}
{ TEGL Windows ToolKit II }
{ Copyright (C) 1990, TEGL Systems Corporation }
{ All Rights Reserved. }
{-----------------------------------------------------------------------------}
{$M 16384, 64000, 655000 }
{$I switches.inc}
USES
Dos,
crt,
errorlog,
TGraph,
{$IFNDEF TEGLDEMO}
teglfnt2,
{$ENDIF}
TeglFont,
FastGrph,
TEGLIntr,
TEGLMenu,
TEGLUnit,
virtmem,
teglmain;
const
BeepTimes : word = 3;
DropClick : word = 0;
DropClick1 : boolean = TRUE;
DropClick2 : boolean = FALSE;
DropClick3 : boolean = FALSE;
{ This event provides the standard exit. }
{$F+}
Function ExitOption(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
BEGIN
AbortExit('Menu keys test');
END;
{ This event is only added by the AddEntry event. When clicked on, this
event drops its own option menu entry from the menu.}
{$F+}
Function DeleteEntry(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
var OM : optionmptr;
begin
{returns the related Option Menu chain}
OM := GetFSOM(fs);
{Drops the current option entry, using the
ms^.clicknumber as the entry number}
DropOptionEntry(OM,ms^.clicknumber);
deleteEntry := 1;
end;
{ AddEntries demonstrates how you can retrieve the current Option Menu and
its related Option entry and insert another option entry into the current
option menu.}
{$F+}
Function AddEntries(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
var OM : optionmptr;
begin
{returns the related Option Menu chain}
OM := GetFSOM(fs);
{sets the Option entry position in preparation of inserting another
entry. If the option entry number is 0, DefineOptions will create
an entry at the beginning of the chain. }
SetCurrentOEPos(OM,ms^.clicknumber-1);
{use the standard DefineOptions()
DefineOptionsRadio()
DefineOptionsCheck()
or DefineOptionsSub()
to create a new entry}
DefineOptions(OM,'~D~elete Entry ',TRUE,deleteentry);
AddEntries := 1;
end;
{ You can change the action of the menu bar to drop down menus in which the
menu drops with a passing of the mouse. "dropclick" is an automatic variable
which is by the menu routines before calling this event. The value in the
"dropclick" is either 0 or 1 as passed by the DefineOptionsRadio() below. }
{$F+}
Function DropClickToggle(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
begin
{resets the complete mouseclick chain stored in a FS to MSClick or
MSSense. MSClick is a boolean value of 0, and MSSense is 1.}
ResetMSClickSense(fs^.relatedstack,boolean(dropclick));
DropClickToggle := 1;
end;
{ Acknowledge is a simple event that aknowledges that it has been called
by beeping. The number of beeps is controlled by the variable Beeptimes;
which is an automatic variable updated by the menu routines. For more
info on automatic variables, look at the menu defines for DefineOptionsRadio(). }
{$F+}
Function Acknowledge(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
var i : word;
BEGIN
{Use WaitforUserRelease to wait for the user to release either the key
or mouse button before proceeding. Waiting for the user to release the
mouse button is not necessary in a menu since the menu waits for you
to release before calling the event. However if you use the same event
for icons or other defined mouse click areas, this event may be
called several times before the button is release.}
WaitForUserRelease;
for i:=1 to BeepTimes do
begin
Beep(1000,1,150);
Beep(500,1,50);
end;
Acknowledge := 1;
END;
{ Defining the option menus may be defined within a procedure or at the
MAIN part of the program. }
procedure CreateMenuBarEvents;
VAR om1,om2,om3,om4,om5,om6 : optionmptr;
begin
{StandardFont is set with the initialization of TEGL in Fastgrph.
When creating Option menus, the proportional flag is saved with
each option menu, therefore if you wish to have non-proportional
menus, you must set the proportional flag off before creating
the option menu.}
setproportional(True);
{OM1 is a standard menu with each entry attached to the Acknowledge event.
The dashed line is used to indicate a line separator between topics.}
{$IFNDEF TEGLDEMO}
standardfont := @ROMAN25;
{$ELSE}
standardfont := @font14;
{$ENDIF}
OM1 := CreateOptionMenu(standardfont);
DefineOptions(OM1,'DeskTop Info...',TRUE,Acknowledge);
DefineOptions(OM1,'--',FALSE,nilunitproc);
DefineOptions(OM1,'Calculator',TRUE,Acknowledge);
DefineOptions(OM1,'Clock',TRUE,Acknowledge);
DefineOptions(OM1,'Snapshot',TRUE,Acknowledge);
{OM2 uses a combination of several features offered in TEGLMENU.
The first is the ">" symbol in Open. This symbol tells the option
menu (when listing) to right justify the remaining portion of the
text.
The curly brackets around F1^ will display F1^ in tiny font.
The tilde ~ character indicates the underscoring of the enclosed
characters, of which the first character becomes the default keyboard
activator.
Global key clicks like Alt-x and ctrl-F1 must be defined using the
definelocal and defineglobal key clicks. The menu routine only
recognizes alphabets and numeric characters when attaching
local key clicks. }
SetMenuMargin(0);
OM2 := CreateOptionMenu(standardfont);
DefineOptions(OM2,'Open >{ctrl-F1}',TRUE,Acknowledge);
DefineOptions(OM2,'Show ~I~nfo...',FALSE,Acknowledge);
DefineOptions(OM2,'--',FALSE,nilunitproc);
DefineOptions(OM2,'~N~ew Folder...',FALSE,Acknowledge);
DefineOptions(OM2,'~C~lose',FALSE,Acknowledge);
DefineOptions(OM2,'Close ~W~indow',FALSE,Acknowledge);
DefineOptions(OM2,'--',FALSE,nilunitproc);
DefineOptions(OM2,'~F~ormat...',TRUE,Acknowledge);
DefineOptions(OM2,'To ~O~utput',TRUE,Acknowledge);
DefineOptions(OM2,'{ALT-X}~Q~uit',TRUE,exitoption);
DefineGlobalKeyClickArea(NIL,NIL,$082d,false,exitoption);
DefineGlobalKeyClickArea(NIL,NIL,$003b,false,Acknowledge);
{ setommaxwidth(om2,50); }
{ DefineOptionsRadio provides a method of toggling between options or
group of options. The controlling variable is updated automatically
by the menu handler before the your event is called. You can use
"Nilunitproc" if you don't need any other activity after the user
has toggle the appropriate menu choices.
The parameters 1,2,3,4 in DefineOptionsRadio is the value that is used
to compare against the variable BeepTimes in determing whether or not
the entry is prefixed with a check mark. When defining radio
entries, be sure to set the menu margins to 10 or more pixels to
allow room for the check mark symbol.}
SetMenuMargin(10);
OM3 := CreateOptionMenu(standardfont);
DefineOptionsRadio(OM3,'~C~lick Menus',TRUE,DropClickToggle,0,DropClick);
DefineOptionsRadio(OM3,'~D~rop Menus',TRUE,DropClickToggle,1,DropClick);
DefineOptions(OM3,'-',FALSE,nilunitproc);
DefineOptionsCheck(OM3,'~A~-Toggle',TRUE,nilunitproc,DropClick1);
DefineOptionsCheck(OM3,'~B~-Toggle',TRUE,nilunitproc,DropClick2);
DefineOptionsCheck(OM3,'~C~-Toggle',TRUE,nilunitproc,DropClick3);
DefineOptions(OM3,'-',FALSE,nilunitproc);
DefineOptionsCheck(OM3,'~S~ound On',TRUE,Acknowledge,BeepStatus);
DefineOptions(OM3,'-',FALSE,nilunitproc);
DefineOptionsRadio(OM3,'Beep ~1~ time ',TRUE,Acknowledge,1,BeepTimes);
DefineOptionsRadio(OM3,'Beep ~2~ times',TRUE,Acknowledge,2,BeepTimes);
DefineOptionsRadio(OM3,'Beep ~3~ times',FALSE,Acknowledge,3,BeepTimes);